home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / hsrc_117.zip / DISPLAY.C < prev    next >
Text File  |  1990-11-14  |  19KB  |  686 lines

  1. #include "msgg.h"
  2. #include "twindow.h"
  3. #include "keys.h"
  4. #include "headedit.h"
  5.  
  6. extern word threadstart;
  7. extern WINDOW *ewnd;
  8. extern int wasconfinedx1,wasconfinedy1,wasconfinedx2,wasconfinedy2;
  9.  
  10. extern void pascal do_recpt(void);
  11.  
  12.  
  13. /* This is the main display function for reading messages
  14.    (see also read_mess()).  This is pretty big and pretty nasty,
  15.    but rather efficient, so what the hell... */
  16.  
  17.  
  18. int pascal display (word *lastmess,char type) {
  19.  
  20.   register word x;
  21.   int  x1;
  22.   int  y1;
  23.   word temp;
  24.   char *hold;
  25.   char *tempo;
  26.   char *p;
  27.   char caret=0;
  28.   char message[133];
  29.   char nextkey;
  30.   char lines;
  31.   char stop;
  32.   word numlines;
  33.   char findend;
  34.   struct nodeidx nid;
  35.   int cx,cy;
  36.  
  37.   if (kbhit()) {
  38.     nextkey=get_char();
  39.     if (nextkey==CTRL_PGUP || nextkey==CTRL_PGDN) return nextkey;
  40.   }
  41. Toggler:
  42.   highvideo();
  43.   current_color=readtextcolor + (readtextback * 16);
  44.   clear_message();
  45.   dclrwnd(1,6,maxx,maxy-1);
  46.   hold=get_text();
  47.   if (hold==NULL || *hold==0) return 0;
  48.   if(tempo=strstr(hold,"\01URGENT")) {
  49.       strncpy(urgent_text,&tempo[8],79);
  50.       urgent_text[78]=0;
  51.       tempo=strchr(urgent_text,'\r');
  52.       if(tempo)*tempo=0;
  53.       lstrip(urgent_text);
  54.       rstrip(urgent_text);
  55.   }
  56.   else *lastmsgid=0;
  57.   if(!threadstart) {
  58.       if(tempo=strstr(hold,"\01MSGID:")) {
  59.         strncpy(lastmsgid,&tempo[7],80);
  60.         lastmsgid[79]=0;
  61.         tempo=strchr(lastmsgid,'\r');
  62.         if(tempo)*tempo=0;
  63.         lstrip(lastmsgid);
  64.         rstrip(lastmsgid);
  65.       }
  66.       else *lastmsgid=0;
  67.       if(tempo=strstr(hold,"\01REPLY:")) {
  68.         strncpy(lastreply,&tempo[7],80);
  69.         lastreply[79]=0;
  70.         tempo=strchr(lastreply,'\r');
  71.         if(tempo)*tempo=0;
  72.         lstrip(lastreply);
  73.         rstrip(lastreply);
  74.       }
  75.       else *lastreply=0;
  76.   }
  77.   if(tempo=strstr(hold,"\01ASSOC:")) {
  78.     strncpy(assocfile,&tempo[7],80);
  79.     assocfile[132]=0;
  80.     tempo=strchr(assocfile,'\r');
  81.     if(tempo)*tempo=0;
  82.     lstrip(assocfile);
  83.     rstrip(assocfile);
  84.   }
  85.   else *assocfile=0;
  86.  
  87.   if (!ctla) strip_seenbys(hold);
  88.   strip_blanklines(hold);
  89.   if (hold==NULL || &hold==NULL) return 0;
  90.   if (kbhit()) {
  91.     nextkey=get_char();
  92.     if (nextkey==CTRL_PGUP || nextkey==CTRL_PGDN) return nextkey;
  93.   }
  94.   if (messno>*lastmess) *lastmess=messno;
  95.   numlines=0;
  96.   line[0]=hold;
  97.   lines=findend=stop=0;
  98.   cx=1;
  99.   cy=6;
  100.   p=hold;
  101.   while (1) {
  102. Continuing:
  103.    if (currarea->attr & ANSI) {
  104.       while(*p) {
  105.         if(*p=='\01' && !ctla) {
  106.             do {
  107.                 p++;
  108.             }while(*p!='\r' && *p);
  109.             if(p)p++;
  110.             continue;
  111.         }
  112.         fputc(*p++,stdout);
  113.         if(cy>(maxy)) cy=maxy;
  114.         if(cy<6) cy=6;
  115.         if (kbhit()) {
  116.             nextkey=toupper(get_char());
  117.             if (nextkey==32) break;
  118.             if (nextkey==80) {
  119.                 while (!kbhit());
  120.                 get_char();
  121.             }
  122.         }
  123.       }
  124.       printf("\r%s",make_ansi(readtextcolor,readtextback));
  125.       goto ReLoop;
  126.    }
  127.    strcpy(message,write_line(&p,maxx,ctla));
  128.    tempo=message;
  129.  
  130.    if (currarea->attr & MCI) {
  131.       if (strchr(tempo,'^')) {
  132.         caret++;
  133.         tempo=mci(tempo);
  134.         if (strlen(tempo)>maxx) {
  135.             if (!findend) lines+=(strlen(tempo)/maxx)+1;
  136.             numlines+=(strlen(tempo)/maxx)+1;
  137.         }
  138.       }
  139.    }
  140.    if (!findend) {
  141.  
  142.       char altered=0;
  143.  
  144.     if(!hilite) {
  145.  
  146.       if(*tempo=='\01') {    /* Highlight kludge lines */
  147.         current_color=kludge_fore + (kludge_back * 16);
  148.         if(caret) fputs(make_ansi(kludge_fore,kludge_back),stdout);
  149.         altered++;
  150.       }
  151.       else if(isbrktquote(tempo)) {    /* Highlight quotes */
  152.             current_color=quote_fore+(quote_back * 16);
  153.             if(caret)fputs(make_ansi(quote_fore,quote_back),stdout);
  154.             altered++;
  155.       }
  156.       else if(currarea->attr & ECHO) {
  157.         if (!strncmp(tempo," * Origin: ",11)) {    /* Highlight origins */
  158.             current_color=orig_fore+(orig_back * 16);
  159.             if(caret)fputs(make_ansi(orig_fore,orig_back),stdout);
  160.             altered++;
  161.           }
  162.           else if (!strncmp(tempo,"--- ",4) || !strcmp(message,"---")) {
  163.             lowvideo();
  164.             current_color=tear_fore+(tear_back * 16);
  165.             if(caret)fputs(make_ansi(tear_fore,tear_back),stdout);
  166.             altered++;
  167.           }
  168.       }
  169.     }
  170.     if (!caret && !slowprint) {
  171.         dputs(cx,cy,tempo);
  172.         cy++;
  173.     }
  174.     else {
  175.         gotoxy(cx,cy);
  176.         if(slowprint) {
  177.  
  178.             char *p;
  179.             unsigned long t1;
  180.  
  181.           p=tempo;
  182.           while(*p) {
  183.              fputc(*p,stdout);
  184.              t1=(unsigned long)biostime(0,0L)+(unsigned long)slowprint;
  185.              while((unsigned long)biostime(0,0L)<t1 && t1<(unsigned long)biostime(0,0L)+256L);
  186.              p++;
  187.           }
  188.           slowprint=0;
  189.         }
  190.         else fputs(tempo,stdout);
  191.         cy++;
  192.     }
  193.  
  194.     if(altered) {
  195.         highvideo();
  196.         current_color=readtextcolor + (readtextback * 16);
  197.         if(caret)fputs(make_ansi(readtextcolor,readtextback),stdout);
  198.     }
  199.  
  200.     caret=0;
  201.     lines++;
  202.    }
  203.    numlines++;
  204.    if (numlines>=(maxlines-1)) numlines=0;
  205.    line[numlines]=p;
  206. EOFF:
  207.    slowprint=0;
  208.    if (currarea->attr & ANSI) goto ReLoop;
  209.    if ((lines>=(maxy-6)-((currarea->attr & MCI)!=0)) || stop || !*p) {
  210.         if (findend) {
  211.             clear_message();
  212.             findend=0;
  213.             numlines-=(maxy-6);
  214.             p=(char *)line[numlines];
  215.             lines=0;
  216.             goto NewPage;
  217.         }
  218.         stop=0;
  219.         if ((numlines>(maxy-6) && lines<(maxy-6)) && !*p) {
  220.             numlines-=(maxy-6);
  221.             p=(char *)line[numlines];
  222.             lines=0;
  223.             goto NewPage;
  224.         }
  225.        while (kbhit()) get_char();
  226. ReLoop:
  227.        cursor(cx-1,cy-1);
  228.        fputs("\r\x1b[0m",stderr);
  229. RealEnd:
  230.        current_color=readheadcolor + (readheadback * 16);
  231.        if (!*p) dputs(70,3," END");
  232.        else if (numlines<=(maxy-6)) dputs(70,3," TOP");
  233.        else dputs(70,3,"MORE");
  234.        dprintf(75,3,"%u",numlines);
  235. FreeKey:
  236.        if(*urgent_text) {
  237.             _anymsg(" URGENT! ",urgent_text);
  238.             *urgent_text=0;
  239.        }
  240.        nextkey=0;
  241.        current_color=readtextcolor + (readtextback * 16);
  242.        set_help ("readkeys  ",0,23);
  243.        SHOWMOUSE;
  244.        if(usemouse) {    /* Allow to roam full screen */
  245.  
  246.           union REGS rg;
  247.  
  248.            rg.x.ax=7;
  249.            rg.x.cx=0;
  250.            rg.x.dx=((maxx-1)*8);
  251.            int86(0x33,&rg,&rg);
  252.            rg.x.ax=8;
  253.            rg.x.cx=0;
  254.            rg.x.dx=((maxy-1)*8);
  255.            int86(0x33,&rg,&rg);
  256.            wasconfinedx1=0;
  257.            wasconfinedy1=0;
  258.            wasconfinedx2=((maxx-1)*8);
  259.            wasconfinedy2=((maxy-1)*8);
  260.        }
  261.        while(!kbhit()) {
  262.           if(usemouse) {
  263.  
  264.                 union REGS rg;
  265.  
  266.                 rg.x.ax=3;
  267.                 int86(0x33,&rg,&rg);
  268.                 move_mouse(rg.x.cx/8,rg.x.dx/8);
  269.                 rg.x.ax=5;
  270.                 rg.x.bx=0;          /* Check left button */
  271.                 int86(0x33,&rg,&rg);
  272.                 if(rg.x.bx) {       /* Button pressed */
  273.                     rg.x.cx/=8;     /* Mouse x */
  274.                     rg.x.dx/=8;     /* Mouse y */
  275.                     if(rg.x.dx<=1) {
  276.                             nextkey='/';
  277.                             break;
  278.                     }
  279.                     if(rg.x.cx==0 && rg.x.dx==(maxy-1)) {
  280.                         nextkey=PGDN;
  281.                         break;
  282.                     }
  283.                     if(rg.x.cx==(maxx-1) && rg.x.dx==(maxy-1)) {
  284.                         nextkey=PGUP;
  285.                         break;
  286.                     }
  287.                     if(rg.x.dx==3 && rg.x.cx>60) {
  288.                         nextkey=ALT_A;
  289.                         break;
  290.                     }
  291.                     if(rg.x.dx==2 && rg.x.cx>29 && rg.x.cx<44) {
  292.                         nextkey=ALT_L;
  293.                         break;
  294.                     }
  295.                     if(rg.x.dx<4) {
  296.                         nextkey=F7;
  297.                         break;
  298.                     }
  299.                     if(rg.x.dx==4) {
  300.                         nextkey=CTRL_N;
  301.                         break;
  302.                     }
  303.                     nextkey=toupper(get_screen_char(rg.x.cx,rg.x.dx));
  304.                     switch((int)nextkey) {
  305.                         case '':   nextkey=CTRL_PGUP;
  306.                                     break;
  307.                         case 26:    nextkey=CTRL_PGDN;
  308.                                     break;
  309.                         case '':   nextkey=DN;
  310.                                     break;
  311.                         case '':   nextkey=UP;
  312.                                     break;
  313.                         case '≈':    nextkey=CTRL_F6;
  314.                                     break;
  315.                         case 168:   set_help ("mousekeys  ",0,23);
  316.                         case '?':   HIDEMOUSE;
  317.                                     if (helpfunc) {
  318.                                        if (!helping) {
  319.                                          helping=1;
  320.